The present invention relates to a mutual exclusion control apparatus for controlling mutual exclusion between a plurality of processors.
The term "mutual exclusion control" means a control for memory access such that only one of a plurality of processors can access at one time to a resource such as a memory region which is shared by the processors. For example, in a case where the respective processors update a shared variable, a certain one of the processors must exclusively perform a processing including "reading" the shared variable from memory, "modifying" it and "rewriting" the modified shared variable to memory. When another processor accesses the shared variable during this processing of the one processor, the access can not be guaranteed as normal. In order to avoid such situation, it is usual to provide a lock variable correspondingly to each shared variable or shared variable region. The lock variable is locked when one processor accesses to the shared variable and unlocked when the access is terminated. Therefore, the access is guaranteed as normal with the mutual exclusion control such that a processor checks the lock variable when it intends to access the corresponding shared variable and accesses it only when the lock variable is in unlocked state.
In the prior art, the lock variables are allocated in a shared memory. The shared memory includes a memory portion for storing the value of lock variables to indicate whether a processor is or is not currently in a critical section. The lock variables may have either an available value indicating that no processor is in a critical section or busy value indicating that processor is in a critical section.
For example, U.S. Pat. No. 5,237,694, issued Aug. 17, 1993 discloses a system and method for use in a processing system of the type including a plurality of processor subsystems, each processor subsystem including a processor, and being coupled together and to a shared memory by a common bus. The lock variables are allocated in the shared memory and cached in a lock buffer. The lock buffer can be servicing lock variable accesses from the common bus while the processor's data cache is serving non-lock variable accesses from the processor. The lock buffer works as a cache memory for lock variables, however, the shared memory allocates the lock variables statically.
In the prior art mentioned above, the lock variables are allocated on the lock table in the shared memory statically. Therefore, if the number of the critical section is increased, the number of lock variables is increased correspondingly. Since the number of the processors which require mutual exclusion control at the same time period for practical programs is limited, it is not always necessary to statically allocate all of the lock variables.
Further, there is another problem that, when there is a failure in a processor which locks the lock variable, it is not easy to unlock the lock variable.